package com.miyake.dsp.converter.ui;

import java.util.ArrayList;
import java.util.List;

import com.miyake.dsp.converter.WindowSetting;
import com.miyake.dsp.ui.DspComboBox;
import com.miyake.dsp.ui.DspWidget;

public class WindowSettingUI extends DspWidget{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private WindowSetting setting;

	public WindowSettingUI(WindowSetting setting) {
		this.setName("Window Setting");
		this.setting = setting;
		createWindowType(setting.getWindow());
	}

	private void createWindowType(int type) {
		final List<String> list = new ArrayList<String>();
		list.add("Hanning");
		list.add("Hamming");
		list.add("Triangle");
		DspComboBox combo = new DspComboBox("Window", list);
		combo.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				int i = 0;
				for (String s : list) {
					if (value.equals(s)) {
						break;
					}
					i++;
				}
				setting.setWindow(i);
				fireChange(value);
			}
		});
		this.add(combo);
	}
}
